package com.kgc.service.impl;


import com.alibaba.dubbo.config.annotation.Reference;
import com.kgc.api.buylimit.CouponApi;
import com.kgc.bean.*;

import com.kgc.service.CouponService;
import com.kgc.util.ReturnResult;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class CouponServiceImpl implements CouponService {
    @Reference(timeout = 30000)
    private CouponApi couponApi;

//    新增优惠券

    public boolean addDiscountTrick(DiscountTrick discountTrick) {
        if (couponApi.addDiscountTrick(discountTrick)) {
            return true;
        }
        return false;
    }

    //用户获取优惠券
    public ReturnResult<String> userAddDiscountTrick(Integer userId, Integer discountTrickId) {
        return couponApi.userAddDiscountTrick(userId, discountTrickId);
    }
//每个优惠券用户领一次

    public boolean checkUserOnlyOne(Integer userId, Integer discountTrickId) {
        return couponApi.checkonly(userId, discountTrickId);
    }

    //获取可获得的所有优惠券
    public List<DiscountTrick> getEnableTrick() {
        return couponApi.getEnableDiscountTrick();
    }

    @Override
    public User selectInfo(Integer userId) {
        return couponApi.selectInfobyId(userId);
    }
}


